package org.imlinker.list;

import java.util.Collection;

import javax.swing.DefaultListModel;

import org.imlinker.plugin.PluginManager;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterEntry;

/**
 * 管理列表在MaiWindow中的显示，包括添加删除ListItem。
 * 
 * （考虑三个列表是否要另外再设置新的类进行管理？）
 * 
 */
public class ListManager {

	public ListManager(Roster roster, PluginManager pluginManager) {
		this.roster = roster;

		messageList = new DefaultListModel();

		buddyList = new DefaultListModel();
		Collection<RosterEntry> enties = roster.getEntries();
		for (RosterEntry entry : enties) {
			buddyList.addElement(new ListItem(null, entry.getName(), null));
		}

		pluginList = new DefaultListModel();
	}

	public DefaultListModel getListModelByName(ListManager.LISTNAME name) {
		if (name == LISTNAME.MESSAGELIST)
			return messageList;

		if (name == LISTNAME.BUDDYLIST)
			return buddyList;

		return pluginList;
	}

	public CellRender getCellRender() {
		return new CellRender();
	}

	public boolean openFirstMessage() {
		// TODO Auto-generated method stub
		return false;
	}

	private DefaultListModel messageList;

	private DefaultListModel buddyList;

	private DefaultListModel pluginList;

	private Roster roster;

	public static enum LISTNAME {
		MESSAGELIST, BUDDYLIST, PLUGINLIST
	}

}
